<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Sa-Token-SSO-Client1端-测试页（前后端分离版）</title>
</head>
<body>
<h2>Sa-Token SSO-Client1 应用端（前后端分离版）</h2>
<p>当前是否登录：<b class="is-login"></b></p>
<p>
  <a href="javascript:location.href='sso-login.html?back=' + encodeURIComponent(location.href);">登录</a>
  <a href="javascript:location.href=baseUrl + '/sso/logout?satoken=' + localStorage.satoken + '&back=' + encodeURIComponent(location.href);">注销</a>
</p>
<script src="https://unpkg.zhimg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script type="text/javascript">

  // 后端接口地址
  var baseUrl = "http://app1.sso.com:9001";

  // 查询当前会话是否登录
  $.ajax({
    url: baseUrl + '/isLogin',
    type: "post",
    dataType: 'json',
    headers: {
      "X-Requested-With": "XMLHttpRequest",
      "satoken": localStorage.getItem("satoken")
    },
    success: function(res){
      $('.is-login').html(res.data + '');
    },
    error: function(xhr, type, errorThrown){
      return alert("异常：" + JSON.stringify(xhr));
    }
  });

</script>
</body>
</html>
